package com.wilmer.knowledges.service.impl;

import com.wilmer.common.annotation.DataScope;
import com.wilmer.common.utils.DateUtils;
import com.wilmer.common.utils.SecurityUtils;
import com.wilmer.knowledges.domain.YwKnowledgeType;
import com.wilmer.knowledges.mapper.YwKnowledgeTypeMapper;
import com.wilmer.knowledges.service.IYwKnowledgeTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 知识库类型Service业务层处理
 * 
 * @author hans
 * @date 2024-04-18
 */
@Service
public class YwKnowledgeTypeServiceImpl implements IYwKnowledgeTypeService
{
    @Autowired
    private YwKnowledgeTypeMapper ywKnowledgeTypeMapper;

    /**
     * 查询知识库类型
     * 
     * @param typeId 知识库类型主键
     * @return 知识库类型
     */
    @Override
    public YwKnowledgeType selectYwKnowledgeTypeByTypeId(Long typeId)
    {
        return ywKnowledgeTypeMapper.selectYwKnowledgeTypeByTypeId(typeId);
    }

    /**
     * 查询知识库类型列表
     * 
     * @param ywKnowledgeType 知识库类型
     * @return 知识库类型
     */
    @DataScope(deptAlias = "d")
    @Override
    public List<YwKnowledgeType> selectYwKnowledgeTypeList(YwKnowledgeType ywKnowledgeType)
    {
        return ywKnowledgeTypeMapper.selectYwKnowledgeTypeList(ywKnowledgeType);
    }

    /**
     * 新增知识库类型
     * 
     * @param ywKnowledgeType 知识库类型
     * @return 结果
     */
    @Override
    public int insertYwKnowledgeType(YwKnowledgeType ywKnowledgeType)
    {
        ywKnowledgeType.setDeptId(SecurityUtils.getDeptId());
        ywKnowledgeType.setCreateTime(DateUtils.getNowDate());
        return ywKnowledgeTypeMapper.insertYwKnowledgeType(ywKnowledgeType);
    }

    /**
     * 修改知识库类型
     * 
     * @param ywKnowledgeType 知识库类型
     * @return 结果
     */
    @Override
    public int updateYwKnowledgeType(YwKnowledgeType ywKnowledgeType)
    {
        ywKnowledgeType.setUpdateTime(DateUtils.getNowDate());
        return ywKnowledgeTypeMapper.updateYwKnowledgeType(ywKnowledgeType);
    }

    /**
     * 批量删除知识库类型
     * 
     * @param typeIds 需要删除的知识库类型主键
     * @return 结果
     */
    @Override
    public int deleteYwKnowledgeTypeByTypeIds(Long[] typeIds)
    {
        return ywKnowledgeTypeMapper.deleteYwKnowledgeTypeByTypeIds(typeIds);
    }

    /**
     * 删除知识库类型信息
     * 
     * @param typeId 知识库类型主键
     * @return 结果
     */
    @Override
    public int deleteYwKnowledgeTypeByTypeId(Long typeId)
    {
        return ywKnowledgeTypeMapper.deleteYwKnowledgeTypeByTypeId(typeId);
    }
}
